-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Introducing choroplethmapbox traces #3988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- valid choropleth datum must have a valid location AND `z` value - set calcdata[i][j].index during calc so that choroplethmapbox can use it in its convert.js
... and update choropleth baselines that
didn't show the "correct" default "black"
for geo AND mapbox base plot modules
... that way we do this only once when geo and mapbox modules
are registered
- reusing choropleth calc, hover, select, eventData and feature2polygon - use `PlotlyGeoAssets` to stash fetched geojson url data - use two layers, one fill (to filled choropleth polygon), one line to draw `marker.line` styles - add mockAxis on mapbox subplot instances, used to format choroplethmapbox 'z' on hover
... similar to how we do things on geo subplots
- use _rehover wrapper similar to cartesian subplots and call it on moveend - split fx init code into prototype.initFx
- where by default chroroplethmapbox traces are placed above the top most "water" layer - N.B. we need to remove/add again layers when *below* is updated
| moduleType: 'trace', | ||
| name: 'choroplethmapbox', | ||
| basePlotModule: require('../../plots/mapbox'), | ||
| categories: ['mapbox', 'gl', 'noOpacity'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on the road, it may be of interest to have traces with opacity. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opacity here for choroplethmapbox traces would be equivalent to marker.opacity, so we don't need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about dimming marker.lines? Trace opacity may be handy for adjusting both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but I'm not going to do this now for consistency with choropleth:
plotly.js/src/traces/choropleth/index.js
Line 26 in cb202a8
| categories: ['geo', 'noOpacity'], |
- move isNonBlankString in outer scope - add "" around URL in invalid-url error msg
... when marker.line.width===0
Introducing densitymapbox traces
|
Is everyone subscribed to this PR ok with the behavior? |
|
No news, good news I guess. Merging this PR into #3987 to have all 1.49.0 mapbox items in one place |
Based off #3987
This PR adds a new mapbox-based trace type:
choroplethmapbox๐ ๐บ๏ธ ๐ฐ๏ธExample: https://codepen.io/etpinard/pen/orGQNe
In brief,
choroplethmapboxtraces have a very similar API as their geo-subplot cousinchoropleth. Both uselocationsandzto set the polygon-to-color mapping. But unlikechoropleth,choroplethmapboxtraces (currently) must be set with ageojsonattribute that contains polygon coordinates.Note that, this PR also fixes a
choroplethbug in 91e0319 - where we didn't use the correctmarker.line.colordefault.Things that work
geojsoncan be set either as URL string or{ }GeoJSON object. We accept GeoJSONs of typeFeatureandFeatureCollectionand geometries of typePolygonandMultiPolygon.choroplethchoroplethlogic, where the polygons' centroid is used.propertiesfields are accessible inhovertemplate(example)Things worthy of discussion
belowdefault.below(like inmapbox.layers) sets theidof the layer just below where thechoroplethmapboxtrace will be plotted. I tentatively chose the layer just above the last "water" layer. That is,choroplethmapboxtraces are plotted below roads and labels by default.below, we could plotchoroplethmapboxtraces above all background layers (but belowscattermapboxtraces) and have a defaultmarker.opacityof e.g. 0.7?Things that we could add
locationmode. The current behavior would correspond tolocationmode: 'geojson-id'. Some users might expect to identify GeoJSON features using theirproperties.name(this would correspond to e.g.locationmode: 'geojson-prop-name'. Moreover, we could also support thelocationmodevalues found in geo traces:'ISO-3', 'USA-states', 'country names'zkeyattribute as an alternative to thezarray. For example,zkey: 'value'would read off theproperties.valuevalues in the GeoJSON set bygeojsoncc @plotly/plotly_js @nicolaskruchten @chriddyp